<%@ page import="java.sql.ResultSet" %>
<html>
<head>
    <script type="text/javascript" language="javascript">
        function validasi() {
            var name = document.getElementById("question").value;
            var pilA = document.getElementById("pilA").value;
            var pilB = document.getElementById("pilB").value;
            var pilC = document.getElementById("pilC").value;
            var pilD = document.getElementById("pilD").value;
            var answer = document.getElementById("answer").value;

            if (name == null || name == "") {
                err.innerHTML = "Please insert the question!";
                return false;
            }


            else if (answer == null || answer == "") {
                err.innerHTML = "Please insert the answer";
                return false;
            }
            else if (answer != pilA && answer != pilB && answer != pilC && answer != pilD) {
                err.innerHTML = "Please insert the right answer based on the option";
                return false;
            }
            else {
                return true;


            }


        }


    </script>
    <link href="style.css" rel="stylesheet"/>
</head>
<body>

<form id="form" method="post" action="doEditPilganGames.jsp" onsubmit="return validasi()">
    <table>
        <div id="popup-header">
            <h2>Edit Question's Details</h2>
        </div>

        <tr>
            <td colspan="2">Question's Type : MultipleChoice</td>

        </tr>

        <%
            rs = stat.executeQuery("select * from DetailGames where detailGamesID = '" + idnya + "' ");
            while (rs.next()) {
                String queID = rs.getString("detailGamesID");
                String pert = rs.getString("question");
                String pilA = rs.getString("Option_1");
                String pilB = rs.getString("Option_2");
                String pilC = rs.getString("Option_3");
                String pilD = rs.getString("Option_4");
                String Ans = rs.getString("Answer");

        %>
    </table>
    <table id="word1">

        <tr>
            <td>Question</td>
            <td>:</td>
            <td><textarea name="question" id="question"><%=pert%>
            </textarea></td>
            <input type="hidden" name="queid" id="queid" value="<%=queID%>">
        </tr>
        <tr>
            <td align="center">A.</td>
            <td></td>
            <td><input type="text" id="pilA" name="pilA" value="<%=pilA%>"></td>
        </tr>

        <tr>
            <td align="center">B.</td>
            <td></td>
            <td><input type="text" id="pilB" name="pilB" value="<%=pilB%>"></td>
        </tr>

        <tr>
            <td align="center">C.</td>
            <td></td>
            <td><input type="text" id="pilC" name="pilC" value="<%=pilC%>"></td>
        </tr>

        <tr>
            <td align="center">D.</td>
            <td></td>
            <td><input type="text" id="pilD" name="pilD" value="<%=pilD%>"></td>
        </tr>
        <tr>
            <td>Answer</td>
            <td>:</td>
            <td><input type="text" name="answer" id="answer" value="<%=Ans%>"></td>
        </tr>
        <tr id="warning">

            <td colspan="3">
                <div id="err"></div>
            </td>
        </tr>

        <tr align="right">
            <td colspan="3">
                <div class="btn-fld">
                    <button type="submit">Save</button>
                </div>

            </td>
        </tr>

        <%}%>
    </table>
</form>
</body>
</html>
